const constant = require("./constant");
const bcconst = require("./bcconst");

function getItemMetaNftType(itemMeta) {
  switch (Number(itemMeta['type'])) {
  case constant.ITEM_HERO_TYPE:
    {
      return bcconst.BC_NFT_HERO;
    }
    break;
  case constant.ITEM_GUN_TYPE:
    {
      return bcconst.BC_NFT_EQUIP;
    }
    break;
  case constant.ITEM_MATERIAL_TYPE:
    {
      if (itemMeta['sub_type'] == constant.ITEM_MATERIAL_CHIP_SUBTYPE_SUBTYPE) {
        return bcconst.BC_NFT_CHIP;
      } else {
        return bcconst.BC_NFT_NONE;
      }
    }
    break;
  case constant.ITEM_CHIP_TYPE:
    {
      return bcconst.BC_NFT_CHIP;
    }
    break;
  case constant.ITEM_BLIND_BOX_TYPE:
    {
      return bcconst.BC_NFT_BLIND_BOX;
    }
    break;
  case constant.ITEM_GOLD_BULLION_TYPE:
    {
      return bcconst.BC_NFT_GOLD_BULLION;
    }
    break;
  default:
    {
      return bcconst.BC_NFT_NONE;
    }
    break;
  }
  return bcconst.BC_NFT_NONE;
}

function getNftTableName(tokenType) {
  switch (Number(tokenType)) {
  case bcconst.BC_NFT_HERO:
  case bcconst.BC_NFT_NORMAL_HERO:
    {
      return 't_hero';
    }
    break;
  case bcconst.BC_NFT_EQUIP:
    {
      return 't_gun';
    }
    break;
  case bcconst.BC_NFT_CHIP:
    {
       return 't_chip';
    }
    break;
  case bcconst.BC_NFT_GOLD_BULLION:
    {
       return 't_gold_bullion';
    }
    break;
  default:
    {
      return '';
    }
    break;
  }
}

function genAirDropTokenId(date, seqId) {
  return bcconst.BC_FUNC_AIRDROP + '' + date + '' + seqId;
}

exports.getItemMetaNftType = getItemMetaNftType;
exports.getNftTableName = getNftTableName;
exports.genAirDropTokenId = genAirDropTokenId;
